package com.alex.hibernate.manager.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alex.hibernate.dao.UserDao;
import com.alex.hibernate.domain.User;
import com.alex.hibernate.manager.UserManager;
//import com.alex.operateionLog.annotation.Action;

/**
 * 
 * @author alex
 */
@Service
@Transactional
public class UserManagerImplHibernate implements UserManager{
	
	@Autowired
	@Qualifier(value="userDaoHibernate")
	private UserDao userDao;
	
	@Transactional
	public void save(User user) throws Exception {
		userDao.save(user);
		if("abc".equals(user.getLoginName())){
			throw new Exception();
		}
	}
	
	@Transactional(readOnly=true)
	public List<User> list(){
		return userDao.list();
	}

	public User load(String id) {
		return userDao.load(id);
	}
	
	public User get(String id) {
		return userDao.get(id);
	}

	public List<User> getAll() {
		return userDao.list();
	}
}
